﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;

namespace SC2Ranks
{
    [DataContract]
    public abstract class BasePlayerInfo
    {
        [DataMember(Name = "id")]
        public int ID { get; set; }

        [DataMember(Name = "bnet_id")]
        public int BattleNetID { get; set; }

        [DataMember(Name = "character_code")]
        public int CharacterCode { get; set; }

        [DataMember(Name = "name")]
        public string Name { get; set; }
    }

    [DataContract]
    public class PlayerInfo : BasePlayerInfo
    {
        [DataMember(Name = "region")]
        protected string RegionRaw { get; set; }

        public Region Region { get { return Helper.ParseRegion(RegionRaw); } }

        [DataMember(Name = "portrait")]
        public PortraitInfo Portrait { get; set; }

        [DataMember(Name = "achievement_points")]
        public int AchievementPoints { get; set; }

        [DataMember(Name = "updated_at")]
        protected string UpdatedAtRaw { get; set; }

        public DateTimeOffset UpdatedAt { get { return DateTimeOffset.Parse(UpdatedAtRaw); } }

        [DataMember(Name = "teams", IsRequired = false)]
        public PlayerTeamInfo[] Teams { get; set; }
    }

    [DataContract(Name = "member")]
    public class TeamMateInfo : BasePlayerInfo 
    {
        [DataMember(Name = "fav_race")]
        protected string FavoriteRaceRaw { get; set; }

        public Race FavoriteRace { get { return Helper.ParseRace(FavoriteRaceRaw); } }
    }
}
